/*
 * boidtype.h
 *
 *  Created on: June 26, 2011
 *      Authors: Lane Aasen, Nikholas Gaffney, Michael Rosenberger, Dylan Swiggett
 */

#ifndef BOIDTYPE_H_
#define BOIDTYPE_H_

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <regex.h>
#include <ctype.h>

#define FSS		1049576 	/*bytes allocated to the file buffer which contains the entire file (currently 1Mb or ~10000 BoidTypes)*/
#define EBS		256		/*bytes allocated to the regex error buffer*/
#define NS		64		/*bytes allocated to the name field*/
#define DS		4096		/*bytes allocated to the data field which contains all field declarations besides name*/
#define FS		64		/*bytes allocated to the field reference*/
#define VS		64		/*bytes allocated to the value of each field*/
#define NMN		3		/*subexpressions + 1 in the name regex*/
#define NMFV	3			/*subexpressions + 1 in the field/value regex*/
#define DEFR	0 			/*default red value*/
#define DEFG	0
#define DEFB	0
#define DEFA	255			/*default alpha value (opaque)*/
#define DEFD	1			/*default density*/
#define DEFAR	14			/*default attraction radius*/
#define DEFRR	10			/*default repulsion radius*/
#define DEFAS	.1			/*default attraction strength*/
#define DEFRS	.17

/*
 * Store colors in RGBA format with float values.
 */
typedef struct {
	int r, g, b;
	float a;
} Color;

/*
 * Struct to be referenced by each boid, defining its properties.
 * Stores all data common to each instance of the boidType.
 */
typedef struct {
	char* name;
	double density;
	Color color;
	double attrRadius, repelRadius;
	double attrStrength, repelStrength;
} BoidType;

/*
 * Load all boidTypes in the specified file. Follow the following syntax:
 *
 * Start the file with the number of BoidTypes to follow
 * Make sure the length of names is no more than 64 characters or the memory might break
 * [name] [r] [g] [b] [attract radius] [repel radius] [attract strength] [repel strength]
 */
void initBoidTypes(char fileName[]);

#endif /* BOIDTYPE_H_ */
